<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>SjoMarks Web</title>
    <link href='http://fonts.googleapis.com/css?family=Nova+Mono' rel='stylesheet' type='text/css'>
    <link href="estilos.css" rel="stylesheet" type="text/css" media="screen" />
    <style type="text/css">
        .style1
        {
            width: 145px;
            height: 145px;
        }
        #sanjoselogo
        {
            height: 173px;
            width: 273px;
        }
    </style>
<link href="inc/jquery-ui-1.8.13.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="inc/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="inc/jquery-ui-1.8.13.custom.min.js"></script>
<script type="text/javascript">
        $(document).ready
		(
			function () 
			{
				$("#campofecha").datepicker
				(
					{
						changeMonth: true,
						changeYear: true,
						dateformat: 'dd-mm-yy'
					}
				);
			}
		)

    </script>
</head>
<body>
<?php
		include('inc/config.php');
    include('inc/functions.php');
		session_start();
      
		  //si la sesion vale 0 (osea no esta logged) te lleva 
		if ($_SESSION['validate'] == 0)
		{
			header('Location: randonm.php');
		}
        
    if (isset($_SESSION['choosen']))
		 {
      $choosengroup = $_SESSION['choosen'];
		}
  
       
		if (!isset($_SESSION['user']))
		{
			header('Location: login.php');
			//echo "<div id='sesion'>Sesion no iniciada</div>";
		}
		else
		{
				$sesionuser = $_SESSION['user'];
				echo "<div id='logout'><h3>Welcome: ".$sesionuser." | <a href='logout.php'>Logout</a></h3></div>";
				$group = $_SESSION['group'];
				$ruta = $_SERVER['SCRIPT_NAME'];
				//echo $ruta;
				$separar = explode('/', $ruta); 
				$contseparadores = count($separar); 
				$resultado = $contseparadores - 1; 
			
					if(($group != "Teacher") && ($separar[$resultado] != "viewmarks.php") && ($separar[$resultado] != "chgpass.php"))  
					{
						header('Location: viewmarks.php');
					}
           if ((!isset($_SESSION['choosen'])) && ($separar[$resultado] != "choosegroup.php"))
          {
             header('Location: choosegroup.php');
          }
		}
?>
<form action="" method="post">
<div id="wrapper">
	<div id="header-wrapper">
		<div id="header">
        <?php
		
		echo "Group: ".$group."<br>";
		if(($group == "Teacher") && ($choosengroup == ""))
		{
			echo "Choosen group: group not selected!";
		}
		else
		{
			echo "Choosen group: ".$choosengroup."";
		}
		?>
		
		<div id="logo">
				<h1><a href="#">SJOMARKS</a></h1>
				  <div id="sanjoselogo">
			    <img alt="" class="style1" 
                    src="http://img.webme.com/pic/c/corjuvenilsantjosepobrer/logo2.jpg" />
                    </div>        
                    </div>
                    </div>
		</div>
	</div>
	<?php
		
		
			
			
			if($group == 'Teacher')  
			{	
				if($choosengroup=="")
				{
					echo <<<res1
					<div id="menu">
						<ul>			
							<li><a href="creategroup.php">Create group</a></li>
							<li><a href="choosegroup.php">Choose group</a></li>
						</ul>
					</div>
res1;
				}
				else
				{
					echo <<<res0
					<div id="menu">
						<ul>			
							<li><a href="creategroup.php">Create group</a></li>
							<li><a href="choosegroup.php">Choose group</a></li>
              <li><a href="deletegroup.php">Delete group</a></li>
							<li><a href="createstudent.php">Create student</a></li>
							<li><a href="createmarks.php">Create mark</a></li>
							<li><a href="viewmarks.php">View Marks</a></li>
              <li><a href="info.php">Info</a></li>
						</ul>
					</div>
res0;
		
				
				}
			}
			else
			{
			echo <<<res2
            <div id="menu">
				<ul>		        
			        <li align='center'><a href="viewmarks.php">View your Marks</a></li>
                 <li align='center'><a href="chgpass.php">Change your password</a></li>
		        </ul>
			</div>
res2;
 } 
?>